package com.bleeth.fx.view.demo4;

import com.bleeth.fx.component.MButton;
import com.bleeth.fx.component.MInput;
import com.bleeth.fx.component.MSwitch;
import com.bleeth.fx.component.MText;
import com.bleeth.fx.helper.SStyleHelper;
import com.bleeth.fx.layout.FormBuilder;
import com.bleeth.fx.layout.GirdCell;
import com.bleeth.fx.meta.IForm;
import com.bleeth.fx.meta.View;
import javafx.beans.property.Property;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;

/**
 * @author Sakura
 * @version 1.0
 * @date 2021-11-13 22:17
 **/
@View(value = "login", type = "begin")
public class LoginView implements IForm {


    @Override
    public Region make(Property... properties) {
        Region leftView = leftView();
        Region rightView = rightView();
        VBox loginView = FormBuilder.form(750D, 500D, Pos.CENTER)
                .addRow( GirdCell.createCell(300D, Pos.CENTER),
                        GirdCell.createCell(450D, Pos.CENTER))
                .coverCell(0, leftView)
                .coverCell(1, rightView)
                .endRow(false)
                .build();

        FormBuilder girdBuilder = FormBuilder.queryForm(loginView);
        HBox row = girdBuilder.queryRow(0).getRow();
        Node node = girdBuilder.queryRowByCell(leftView).getRow().getChildren().get(0);
        Node node1 = girdBuilder.queryRowByCell(leftView).getRow().getChildren().get(1);


        SStyleHelper.node(row)
                .addStyle("-fx-background-color", "transparent")
                .addStyle("-fx-background-radius", "20 20 20 20")
                .apply();


        SStyleHelper.node(node)
                .addStyle("-fx-background-color", "transparent")
                .addStyle("-fx-background-radius", "20 20 20 20")
                .apply();
/*
        SStyleHelper.node(node1)
//                .addStyle("-fx-background-color", "transparent")
                .addStyle("-fx-background-radius", "20 20 20 20")
                .apply();
*/
        SStyleHelper.node(loginView)
                .addStyle("-fx-background-color", "transparent")
                .addStyle("-fx-background-radius", "20 20 20 20")
                .addStyle("-fx-border-radius", "20 20 20 20")
                .apply();
        return loginView;
    }

    @Override
    public void css() {

    }


    public Region leftView() {
        VBox leftView = FormBuilder.form(null, 500D)
                .addEmptyRow(120D)

                .addRow(GirdCell.createCell(1, Pos.CENTER))
                .addCell(0, MText.builder().text("欢迎").color("#f4f4f4").size(40).build().make())
                .endRow(false)
                .addEmptyRow(30D)

                .addRow(GirdCell.createCell(1, Pos.CENTER))
                .addCell(0, MText.builder().text("登录访问您的系统").color("#f4f4f4").size(25).build().make())
                .endRow(false)
                .addEmptyRow(30D)

                .coverRow(GirdCell.createCell(1, Pos.CENTER))
                .coverCell(0, MText.builder().text("天天科技 版权所有").color("#f4f4f4").size(14).pos(Pos.BOTTOM_CENTER).build().make())
                .endRow(false)

                .build();
//        StyleHelper.bg(leftView).color("#a4c1dc").radius(20).make();
        SStyleHelper.node(leftView)
                .addStyle("-fx-background-color", "linear-gradient(to bottom ,#e56568,#9793e0)")
                .addStyle("-fx-effect", "dropshadow( gaussian , rgba(255,255,255,0.5) , 0,0,0,1 )")
                .addStyle("-fx-background-radius", "20 0 0 20")
                .apply();
        return leftView;
    }

    public Region rightView() {
        VBox rightView = FormBuilder.form(null, 500D)
                .addEmptyRow(50D)

                .addRow(GirdCell.createCell(1, Pos.CENTER))
                .addCell(0, MText.builder().text("登录").color("#757575").size(35).build().make())
                .endRow(false)
                .addEmptyRow(25D)

                .addRow(GirdCell.createCell(70D, Pos.CENTER), GirdCell.createCell(1, Pos.CENTER_LEFT), GirdCell.createCell(70D, Pos.CENTER))
                .addCell(1, MText.builder().text("用户名").color("#716b67").size(20).build().make())
                .endRow(false)
                .addEmptyRow(10D)

                .addRow(GirdCell.createCell(70D, Pos.CENTER), GirdCell.createCell(1, Pos.CENTER), GirdCell.createCell(70D, Pos.CENTER)) //username
                .addCell(1, MInput.builder().icon("icon-user").placeholder("请输入用户名").build().make())
                .endRow(false)
                .addEmptyRow(30D)

                .addRow(GirdCell.createCell(70D, Pos.CENTER), GirdCell.createCell(1, Pos.CENTER_LEFT), GirdCell.createCell(70D, Pos.CENTER))
                .addCell(1, MText.builder().text("密码").color("#716b67").size(20).build().make())
                .endRow(false)
                .addEmptyRow(10D)

                .addRow(GirdCell.createCell(70D, Pos.CENTER), GirdCell.createCell(1, Pos.CENTER), GirdCell.createCell(70D, Pos.CENTER))
                .addCell(1, MInput.builder().icon("icon-user").placeholder("请输入密码").build().make())
                .endRow(false)
                .addEmptyRow(30D)

                .addRow(GirdCell.createCell(70D, Pos.CENTER), GirdCell.createCell(1, Pos.CENTER_LEFT), GirdCell.createCell(70D, Pos.CENTER))
                .addCell(1, MSwitch.builder().rightText("记住我").build().make())
                .endRow(false)
                .addEmptyRow(30D)

                .addRow(GirdCell.createCell(70D, Pos.CENTER), GirdCell.createCell(1, Pos.CENTER), GirdCell.createCell(70D, Pos.CENTER))
                .addCell(1, MButton.builder().text("登   路").type("primary").build().make())
                .endRow(false, 10)

                .build();
        SStyleHelper.node(rightView)
                .addStyle("-fx-background-color", "#dadada55")
                .addStyle("-fx-background-radius", "0 20 20 0")
                .apply();
        return rightView;
    }


}
